# -*- coding: utf-8 -*-
import os
from liberLibs import utils
import subprocess


def execute(hook):
    if hook == "show_in_rv":
        temp_file = utils.temp_file("liber_rv_list.json")
        if os.path.isfile(temp_file):
            try:
                files = utils.read_json(temp_file)
                cmd = "rv -play %s" % (" ".join(files))
                subprocess.Popen(cmd, shell=True)
            except Exception as e:
                print str(e)
            finally:
                os.remove(temp_file)
